

var detectCycle = function(head) {
    let cur = head
    while(cur) {
        if(cur.flag){
            return cur
        }
        else {
            cur.flag = true
            cur = cur.next
        }
    }
    return null
}; 